<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/common/hplus-css.jsp"%>
    <%@include file="/WEB-INF/common/hplus-js.jsp" %>
</head>
<body class="gray-bg">
     <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <form action="${path}/user/edit" class="form-horizontal m-t" id="userForm" method="post">
                            <input id="id" name="id" type="hidden" value="${user.id}">
                            <input  name="pid" id="pid" type="hidden" value="">
                            <input  name="orgId" type="hidden" value="${user.orgId}">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">账号：</label>
                                <div class="col-sm-8">
                                    <input type="text" minlength="2" class="form-control" disabled value="${user.userCode}">
                                </div>
                            </div>
<%--                            <div class="form-group">--%>
<%--                                <label class="col-sm-3 control-label">上级部门：</label>--%>
<%--                                <div class="col-sm-8">--%>
<%--                                    <input type="text" id="name" minlength="2" class="form-control" onclick="choose()" placeholder="点击选择部门">--%>
<%--                                </div>--%>
<%--                            </div>--%>
                             <div class="form-group">
                                <label class="col-sm-3 control-label">用户名：</label>
                                <div class="col-sm-8">
                                    <input type="text"  name="name"  class="form-control" maxlength="11" required=""
                                    onkeyup="value=value.replace(/[\u4e00-\u9fa5]/ig,'')" value="${user.name}">
                                </div>
                            </div>
                             <div class="form-group">
                                <label class="col-sm-3 control-label">密码：</label>
                                <div class="col-sm-8">
                                    <input type="password" class="form-control" name="password" maxlength="6" placeholder="不修改密码请留空">
                                </div>
                            </div>

                              <div class="form-group">
                                <label class="col-sm-3 control-label">真实性名：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="trueName" name="trueName" minlength="2" maxlength="24" class="form-control"  value="${user.trueName}">
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-3 control-label">手机号：</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="mobile"  isPhone="true"  value="${user.mobile}">
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-3 control-label">性别：</label>
                                <div class="col-sm-8">
                                    <select class="form-control m-b" name="gender">
                                        <option value="1" ${user.gender == 1?"selected='selected'":""}>男</option>
                                        <option value="0" ${user.gender == 0?"selected='selected'":""}>女</option>
                                    </select>
								</div>
                            </div>


							<div class="form-group" id="showName" style="display: none"  >
								<label class="col-sm-2 control-label"></label>
								<img id="imageView" src="" style="height:120px;width:120px;display: none;"/>
							</div>
                             <div class="form-group">
                                <label class="col-sm-3 control-label">用户角色：</label>
                                <div class="col-sm-8" id="roles">
                                      <c:forEach items="${roles}" var="role" varStatus="i">
			                            <label class="radio-inline i-checks">
	                                        <div class="iradio_square-green<c:forEach var="ur" items="${user.roles}" varStatus="i"><c:if test="${ur.id == role.id}"> checked='checked' </c:if></c:forEach>" style="position: relative;">
	                                           <input name="roleId" type="radio" style="position: absolute; opacity: 0;" value="${role.id}" <c:forEach var="ur" items="${user.roles}" varStatus="i"><c:if test="${ur.id == role.id}"> checked</c:if></c:forEach>>
	                                           <ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins>
	                                        </div>
	                                        ${role.nameZh}
	                                    </label>
			                        </c:forEach>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button class="btn btn-primary" id="update-btn" type="button">修改用户</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@include file="/WEB-INF/common/hplus-js.jsp"%>
    <script src="${path}/assets/hplus/js/demo/form-validate-demo.js"></script>
    <script>
        $(document).ready(function () {
        	
        	$("#userForm").validate();
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
            $("#update-btn").click(function() {
            	var types=${user.type};

            	var valid = $("#userForm").valid();
            	if(valid) {
            		formSubmit("userForm");
            	}
            });
        });
        function imageCallBak(data) {
			$("#imageView").attr("src","${downloadBasePath}" + data.path);
			$("#imageView").show();
		}

        var index =null;
        function choose() {
            index =  layer.open({
                type: 2,
                title: '',
                shadeClose: true,
                shade: 0.5,
                area: ['800px', '60%'],
                content: '${path}/organ/tree' //iframe的url
            });
        }

        function closeTree(id,name) {
            console.log("id="+id);
            $("#pid").val(id);
            $("#name").val(name);
            layer.close(index);
        }
    </script>
</body>
</html>
